import Taro, { Component } from '@tarojs/taro'
import { View , Text , Image} from '@tarojs/components';
import { baseImgSrc } from '../../util/base_url';
import { AtRate} from 'taro-ui';
import { getUserComment } from '../../util/api';
import NoData from '../../components/nodata/nodata';
import './commentList.scss';
export default class About extends Component {
    constructor(){
        super(...arguments)
        this.state = {
            id:"",
            list:[],
        };
    }
    config = {
        navigationBarTitleText:"评论",
    }
    componentWillMount(){
        this.setState({id:this.$router.params.id});
        getUserComment({user_id:this.$router.params.id}).then( res => {
            if(res.code == 0){
                console.log(res)
                this.setState({
                    list:res.data
                })
            }
        })
    }
    render(){
        const { list } = this.state;
        return(
            <View className='about'>
                <View className='list'>
                    {
                        list.length > 0 ?  list.map((v,i) => (
                            <View className='item flex align-content-start space-between'>
                                <Image className='heading' src={v.headimg} />
                                <View className='right flex1'>
                                    <View className='name flex align-items space-between'>
                                        <Text className='txt'>{v.nickname}</Text>
                                        <Text className='time'>{v.user_time}</Text>
                                    </View>
                                    <AtRate value={v.user_score} size={15} margin={15} onChange={() => false} />
                                    <View className='comment-value'>{v.user_cont}</View>
                                </View>
                            </View>
                        )) : <NoData needShow={list.length == 0}  />
                    }
                </View>
            </View>
        )
    }
}